<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加菜单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" type="text/css" th:href="@{/js/layui/css/layui.css}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/fyn/style.css/}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/fyn/my.css/}" media="all">
</head>
<body class="childrenBody">
<form class="layui-form html_save" lay-filter="form">

    <blockquote class="layui-elem-quote">默认所有人都有建群权限</blockquote>


    <div class="layui-form-item">
        <label class="layui-form-label">权限状态</label>
        <div class="layui-input-block">
            <input type="checkbox" name="status" checked lay-skin="switch" lay-filter="status" lay-text="开启|部分权限"
                   id="status">
        </div>
    </div>

    <div class="layui-form-item" id="dis" style="display: none;">
        <div class="layui-input-block">
            <button type="button" id="choose" class="layui-btn ">添加</button>
            <table class="layui-table">
                <colgroup>
                    <col width="150">
                    <col width="200">
                    <col>
                </colgroup>
                <thead>
                <tr>
                    <th>头像</th>
                    <th>昵称</th>
                    <th>APPId</th>

                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>贤心</td>
                    <td>2016-11-29</td>
                    <td>人生就像是一场修行</td>
                </tr>

                </tbody>
            </table>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="saveContainer">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>

    </div>




</form>
<script th:src="@{/js/layui/layui.js}"></script>
<script th:src="@{/js/cba/login-timeout.js}"></script>
<!--<script type="text/javascript" src="js/newsadd.js"></script>-->

<script type="text/javascript" th:inline="javascript">
    layui.use(['table', 'form', "layer"], function () {

        // 操作对象
        var form = layui.form
            , table = layui.table
            , layer = layui.layer
            , $ = layui.jquery;


        /*if (menu.status == 1) {
            $("#status").removeAttr("checked");
        }*/


        form.on('switch(status)', function (data) {
            console.log(data.elem); //得到checkbox原始DOM对象
            //console.log(); //开关是否开启，true或者false
            console.log(data.value); //开关value值，也可以通过data.elem.value得到
            console.log(data.othis); //得到美化后的DOM对象

            if (data.elem.checked) {//

                $("#dis").css("display",'none');

            }else{
                $("#dis").css("display",'');
            }
        });

        //选择用户 choose
        $("#choose").click(function () {
            
        })


        //监听提交
        form.on('submit(saveContainer)', function (data) {

            data.field.status = data.field.status == "on" ? 0 : 1;
            $.ajax({
                url: [[${basePath}]] + "/menu/save", data: data.field, sync: "post", success: function (data) {

                    if (data.success) {
                        layer.msg(data.msg, {icon: 1});
                        setTimeout(function () {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.location.href = [[${basePath}]] + "/menu/index";
                            parent.layer.close(index);
                        }, 1500);
                    } else {
                        layer.msg(data.msg, {icon: 5});
                    }
                }
            });

            return false;
        });

    });
</script>
</body>
</html>